﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NextAction.Domain.Abstract;
using NextAction.WebUI.Models;
using NextAction.Domain.Entities;

namespace NextAction.WebUI.Controllers
{
    public class CollectionController : AbstractGtdController
    {
         public CollectionController(IGtdEnityRepository gtdRepository)
            : base(gtdRepository)
        {
        }

        public ActionResult Index()
        {
            return View(CreateViewModel());
        }

        private CollectionViewModel CreateViewModel()
        {
            return new CollectionViewModel()
            {
                BucketSizes = repository.GetBucketSizes()
            };
        }

        public JsonResult GetBucketSizes()
        {
            var sizes = repository.GetBucketSizes();
            var bucketSizes = new
            {
                Inbox = sizes[BucketType.Inbox],
                Next = sizes[BucketType.Next],
                Today = sizes[BucketType.Today],
                Tomorrow = sizes[BucketType.Tomorrow],
                Scheduled = sizes[BucketType.Scheduled],
                Wait = sizes[BucketType.Wait],
                Someday = sizes[BucketType.Someday]
            };
            return Json(bucketSizes, JsonRequestBehavior.AllowGet);
        }


    }
}
